<?php

/**
 * model_record
 */

class Model_record extends YOU {

	public function __construct()
	{
		parent::__construct();
	}

	/** 读取项目信息 **/
	public function getInfo($record_type = "")
	{
		$record_data = $this->db->fetchRow("SELECT `record_name` FROM `tbl_record` WHERE record_type='{$record_type}'");
		$record_name = unserialize($record_data['record_name']);

		return $record_name;
	}

	/** 修改项目 **/
	public function update($record_type = "", $record_name = array() )
	{	
		
		// 序列化
		$record_name = serialize($record_name);
		
		$info = array
		(
		"record_type" => $record_type,
		"record_name" => $record_name,
		"update_time" => date("Y-m-d H:i:s"),
		);

		$this->db->do_update("tbl_record", $info, "record_type='{$record_type}'");
	}

	/** 得到选中后的配置 **/
	public function getCheck($record_type = "", $record_ini = array() )
	{
		$record_name = $this->getInfo($record_type);
		foreach($record_name as $key => $value){
			$record[$value['name']] = $value['title'];
		}
		foreach($record_ini as $key => $value){
			if(!empty($record[$value['name']])){
				$record_ini[$key]['check'] = 1;
			}
		}

		return $record_ini;
	}

}



?>